home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / mmdf / mmdf-IIb.43 / libz / asctime.c next >
Encoding:
C/C++ Source or Header  |  1989-06-23  |  885 b   |  45 lines

  1. #
  2.  
  3. /*LINTLIBRARY*/
  4.  
  5. #include "stdio.h"
  6.  
  7. #ifndef lint
  8. #ifndef NOID
  9. static char    sccsid[] = "@(#)asctime.c    3.2";
  10. #endif /* !NOID */
  11. #endif /* !lint */
  12.  
  13. #include "time.h"
  14. #include "tzfile.h"
  15.  
  16. #if defined(USG) || defined(SYS5)    /* Added SYS5. ECB 10/88 */
  17. extern char *    sprintf();
  18. #endif /* !USG */
  19.  
  20. /*
  21. ** A la X3J11
  22. */
  23.  
  24. char *
  25. asctime(timeptr)
  26. register struct tm *    timeptr;
  27. {
  28.     static char    wday_name[DAYS_PER_WEEK][3] = {
  29.         "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  30.     };
  31.     static char    mon_name[MONS_PER_YEAR][3] = {
  32.         "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  33.         "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  34.     };
  35.     static char    result[26];
  36.  
  37.     (void) sprintf(result, "%.3s %.3s%3d %02.2d:%02.2d:%02.2d %d\n",
  38.         wday_name[timeptr->tm_wday],
  39.         mon_name[timeptr->tm_mon],
  40.         timeptr->tm_mday, timeptr->tm_hour,
  41.         timeptr->tm_min, timeptr->tm_sec,
  42.         TM_YEAR_BASE + timeptr->tm_year);
  43.     return result;
  44. }
  45.